﻿package com.kuanter.kuanterauto.activity;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;

import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewDebug.FlagToString;
import android.view.WindowManager.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.kuanter.kuanterauto.R;
import com.kuanter.kuanterauto.adapter.CarListAdapter;
import com.kuanter.kuanterauto.baseui.BaseActivity_NoBar;
import com.kuanter.kuanterauto.baseui.ProApplication;
import com.kuanter.kuanterauto.cache.ObjectCache;
import com.kuanter.kuanterauto.constants.HttpConfigAPI;
import com.kuanter.kuanterauto.constants.MainConstants;
import com.kuanter.kuanterauto.dataservices.PushServices;
import com.kuanter.kuanterauto.entity.AccountInfo;
import com.kuanter.kuanterauto.entity.CardInfo;
import com.kuanter.kuanterauto.entity.UserInfo;
import com.kuanter.kuanterauto.entity.VehicleInfo;
import com.kuanter.kuanterauto.entity.VehicleInfoList;
import com.kuanter.kuanterauto.main.HomeActivityGroup;
import com.kuanter.kuanterauto.net.HttpTask;
import com.kuanter.kuanterauto.utils.AnimationController;
import com.kuanter.kuanterauto.utils.DataLoader;
import com.kuanter.kuanterauto.utils.DimensUtil;
import com.kuanter.kuanterauto.utils.DrawNumber;
import com.kuanter.kuanterauto.utils.JsonParser;
import com.kuanter.kuanterauto.utils.SharePrefenceUtil;
import com.kuanter.kuanterauto.utils.StringUtil;
/**
 * 我的宽途
 * @author kuanter
 *
 */
public class VipCenterActivity extends BaseActivity_NoBar implements View.OnClickListener {//implements CallBack ,IWXAPIEventHandler

	private Intent intent = new Intent();
	private TextView account_name_title;
	private View personal_info_goto;
	private View my_consumer_log_goto;
	private View my_kuanter_card_goto;
	private View my_car_goto;
	private View recharge_goto;
	private View activate_card_goto;

	public static boolean toastJH = false;
	public static boolean toastZC = false;
	
	private UserInfo userInfo;
	private TextView logout_tv;
	private String saveMoney = "0.00";
	/**
	 * 请求节约金额响应
	 *
	 */
	Handler handler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case HttpTask.RESULT_OK:
				finishProgress();
				String result = (String) msg.obj;
				if (!result.equals("网络连接错误")) {
					try {
						if (StringUtil.isSuccess(result)) {// 判断返回数据中 status
							JSONObject jsonObject = JSON.parseObject(result);
							saveMoney = jsonObject.getString("savedMoney");
							application.setSaveMoney(saveMoney);
							saveJinE.setText(saveMoney);
						} 
					} catch (JSONException e) {
						e.printStackTrace();
					}
				} else {
					Toast.makeText(VipCenterActivity.this, "网络连接错误!", 0).show();
				}
				break;
			case HttpTask.RESULT_ERROR:  
				Toast.makeText(VipCenterActivity.this, "网络错误!", 0).show();
				break;
			}
		}
	};
	protected List<CardInfo> cardInfos;
	/**
	 * 请求查询卡片响应
	 *
	 */
	Handler handler_QUERY_CARD = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case HttpTask.RESULT_OK:
				finishProgress();
//				String result = msg.getData().getString("result");
				String result = (String) msg.obj;
				if (!result.equals("网络连接错误")) {
					try {
						if (StringUtil.isSuccess(result)) {// 判断返回数据中 status
															// 字段值是否为false
							com.alibaba.fastjson.JSONObject jsonObjectResult = JSON
									.parseObject(result);
							if(null != jsonObjectResult
									.getString("cardInfoList")){
								String JsonStringUserInfo = jsonObjectResult
										.getString("cardInfoList");
								cardInfos = JSON.parseArray(
										JsonStringUserInfo, CardInfo.class);
								ProApplication.getInstance().setCardInfoList(cardInfos);
								//设置欢迎信息（账户金额，累计节省）
								setWelcomeInfo(cardInfos,accountJinE);
								/*// 将cardInfoList缓存
								ObjectCache.set("cardInfoList", cardInfos);
								application = (ProApplication)getApplication();
								application.setCardInfoList(cardInfos);*/
								
							}
							finishProgress();
						} else {
							finishProgress();
							// 显示返回数据中 errorMsg 字段值
							showToast("失败");
						}
					} catch (JSONException e) {
						finishProgress();
						showToast("登录失败");
						e.printStackTrace();
					}
				} else {
					finishProgress();
					showToast("登录失败,网络错误!");
				}
				break;
			case HttpTask.RESULT_ERROR:
				finishProgress();
				showToast("网络错误!");
				break;
			}
		}

	};
	//设置欢迎信息
	private void setWelcomeInfo(List<CardInfo> cardInfos,TextView accountJinE) {
		//账户金额
		int countBalances = 0;//洗车总次数
		double pointBalances = 0;//剩余总积分
		if(null != cardInfos){
			for(CardInfo cardInfo : cardInfos){
				if(null != cardInfo.getAccountList()){
					for(AccountInfo accountInfo : cardInfo.getAccountList()){
						if(accountInfo.getAccountTypeName().equals("积分")){
//							Log.i("wuyang", accountInfo.getAccountTypeName());
							if(!"".equals(accountInfo.getBalance())){
								pointBalances = pointBalances + Double.parseDouble(accountInfo.getBalance());
							}
						}else if(accountInfo.getAccountTypeName().equals("次数")){
							if(!"".equals(accountInfo.getBalance())){
								countBalances = countBalances + (int)(double)Double.parseDouble(accountInfo.getBalance());
							}
						}
					}
				}
			}
			/*pointBalances = 10000d;
			countBalances = 100;*/
			DecimalFormat df=new DecimalFormat("#.##");
			if(df.format(pointBalances).length()+String.valueOf(countBalances).length()>7){
				rl_account_2_lines.setVisibility(View.INVISIBLE);
				rl_account_3_lines.setVisibility(View.VISIBLE);
				accountJinE = (TextView)this.findViewById(R.id.textView25);
				accountCiShu = (TextView)this.findViewById(R.id.textView26);
				accountJinE.setText(df.format(pointBalances));
				accountCiShu.setText(countBalances+"");
			}else {
				rl_account_2_lines.setVisibility(View.VISIBLE);
				rl_account_3_lines.setVisibility(View.INVISIBLE);
				accountJinE = (TextView)this.findViewById(R.id.textView5);
				accountCiShu = (TextView)this.findViewById(R.id.textView11);
				accountJinE.setText(df.format(pointBalances));
				accountCiShu.setText(countBalances+"");
			}
		}
//		DecimalFormat df=new DecimalFormat("#.##");
//		
//		if(accountJinE != null ){
//		}
//		if(null != accountCiShu){
//		}
	}
	private ProApplication application;
	private TextView personXing;
	private TextView personPhone;
	private TextView accountJinE;
	private TextView saveJinE;
	private SharedPreferences sp;
	private DataLoader dataLoader;
	private View account_include;
	private TextView login;
	private TextView accountCiShu;
	private TextView accountTitle;
	private TextView saveTitle;
	private RelativeLayout rl_account_2_lines;
	private RelativeLayout rl_account_3_lines;
	public static String show_action = "com.show.message";
	public static final int show = 0;
	
	
	/**
	 * 登陆接口响应值
	 */
	Handler handler_login = new Handler() {
		
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case HttpTask.RESULT_OK:
				// {"status":false,"errorMsg":null}
				// {"status":true,"userInfo":{"id":82739,"mobileNumber":"18638551072","userEmail":"hncaihongyu@163.com","userRealName":"蔡红玉"}}
//				String result = msg.getData().getString("result");
				String result = (String) msg.obj;
				if (!result.equals("网络连接错误")) {
					try {
						if (StringUtil.isSuccess(result)) {// 判断返回数据中 status
							ityoung();
						} else {
							// 显示返回数据中 errorMsg 字段值
							Editor editor = getSharedPreferences(SharePrefenceUtil.USERINFO, MODE_PRIVATE).edit();
							editor.putString("id", "0");
							editor.commit();
							ityoung();
							/*account_include.setVisibility(View.GONE);
							personal_info_goto.setVisibility(View.GONE);
							recharge_goto.setBackgroundResource(R.drawable.item_selector);
							logout_tv.setVisibility(View.GONE);
							login.setVisibility(View.VISIBLE);*/
							showToast("资料修改，请重新登陆");
							
							ServicesActivity.NocticeShow= false; //通知初始化
							lin_cx_ad.setVisibility(View.GONE);
							noticeAll.clear();
							falg = true;
							NocticeShow = false;
						}
					} catch (JSONException e) {
						showToast("登录失败");
						e.printStackTrace();
					}
				} else {
					showToast("登录失败,网络错误!");
				}
				break;
			case HttpTask.RESULT_ERROR:
				showToast("网络错误!");
				break;
			}
		}
	};
	private TextView call_tv;
	private TextView register_tv;
	private View setting_my_message;
	private TextView setting_my_message_title;
	private LayoutInflater factory;
	private ImageView bubble;
	private DrawNumber drawNumber;
	
	private ImageView location2noCardPay;  //无卡支付弹出层
	private RelativeLayout noCardPayPosition;
	private TextView tmp123;
	
	RelativeLayout lin_top;
	
	ImageView iv_toast_cz;
	ImageView iv_jf;  //  账户余额弹出层
	RelativeLayout layout_re_top;
	RelativeLayout vip_toast;  //弹出窗口层
	ImageView iv_jh_ok;  //激活成功或注册成功
	
	LinearLayout re_zh;
	LinearLayout re_wk;
	LinearLayout re_cz;
	
	ScrollView vip_scroll;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.vip_center);
		noCardPayPosition = (RelativeLayout)findViewById(R.id.noCardPayPosition);
		tmp123 = (TextView)findViewById(R.id.tmp123);
		lin_top = (RelativeLayout) findViewById(R.id.lin_top);
		
		iv_toast_cz = (ImageView) findViewById(R.id.iv_toast_cz);
		location2noCardPay = (ImageView)findViewById(R.id.location2noCardPay);
		iv_jf = (ImageView) findViewById(R.id.iv_jf);
		//框框
//		iv_toast_cz.setImageResource(R.drawable.toast_cz);
//		iv_jf.setImageResource(R.drawable.toast_zh);  //TODO
//		location2noCardPay.setImageResource(R.drawable.toast_wk);
		
		location2noCardPay.setImageResource(R.drawable.toast_kk);
		iv_toast_cz.setImageResource(R.drawable.toast_kk);
		iv_jf.setImageResource(R.drawable.toast_kk);
		
		
		layout_re_top = (RelativeLayout) findViewById(R.id.layout_re_top);
		iv_jh_ok = (ImageView) findViewById(R.id.iv_jh_ok);
		iv_jh_ok.setImageResource(R.drawable.jh_ok);
		
		vip_scroll = (ScrollView) findViewById(R.id.vip_scroll);
		//TODO
		re_zh = (LinearLayout) findViewById(R.id.re_zh);
		re_wk = (LinearLayout) findViewById(R.id.re_wk);
		re_cz = (LinearLayout) findViewById(R.id.re_cz);
		
		vip_toast = (RelativeLayout) findViewById(R.id.vip_toast);
		vip_toast.setVisibility(View.GONE);
		vip_toast.setOnTouchListener(new OnTouchListener() {
			@Override
			public boolean onTouch(View view, MotionEvent motionevent) {
				vip_toast.setVisibility(View.GONE);
				return true;
			}
		});
		
		factory = getLayoutInflater();
		bubble = (ImageView)this.findViewById(R.id.bubble);
		drawNumber = new DrawNumber(this);
		//获取新消息数
		int messageNumber = PushServices.unReadMessage;
		View v = factory.inflate(R.layout.draw_number, null);
//		if(null != PushServices.getmessageInfos()){
//			messageNumber = PushServices.getmessageInfos().size();
			if(messageNumber > 0){
				bubble.setVisibility(View.VISIBLE);
				Bitmap bitmap = drawNumber.generatorContactCountIcon(drawNumber.convertViewToBitmap(v),messageNumber);
				bubble.setImageBitmap(bitmap);
			}else{
				bubble.setVisibility(View.GONE);
			}
		
		sp = getSharedPreferences(SharePrefenceUtil.USERINFO, MODE_PRIVATE);
		application = (ProApplication)getApplication();
		rl_account_2_lines = (RelativeLayout)findViewById(R.id.rl_account_2_lines);
		rl_account_3_lines = (RelativeLayout)findViewById(R.id.rl_account_3_lines);
		//控件
		// 我的消息
				setting_my_message = this.findViewById(R.id.setting_my_message);
				setting_my_message.setOnClickListener(this);
				setting_my_message_title = (TextView)setting_my_message.findViewById(R.id.include_image_1tv_drawable_right_image_TV);
				setting_my_message_title.setText("我的消息");
//				account_name_title = (TextView) this.findViewById(R.id.include_image_2tv_arrow_TVtitle);
//				account_name_title.setText("修改信息");
				personal_info_goto = this.findViewById(R.id.personal_info_goto);
				my_consumer_log_goto = this.findViewById(R.id.my_consumer_log_goto);
				my_kuanter_card_goto = this.findViewById(R.id.my_kuanter_card_goto);
				my_car_goto = this.findViewById(R.id.my_car_goto);
				recharge_goto = this.findViewById(R.id.recharge_goto);
				activate_card_goto = this.findViewById(R.id.activate_card_goto);
				logout_tv = (TextView) this.findViewById(R.id.logout_tv);
				login = (TextView)this.findViewById(R.id.login);
				personXing = (TextView)this.findViewById(R.id.textView2);
				personPhone = (TextView)this.findViewById(R.id.textView3);
				accountTitle = (TextView)this.findViewById(R.id.textView4);
				saveTitle = (TextView)this.findViewById(R.id.textView9);
//				saveTitle.getPaint().setFakeBoldText(true);//加粗  
				saveJinE = (TextView)this.findViewById(R.id.textView6);
				account_include = this.findViewById(R.id.account_include);
				
				call_tv = (TextView)findViewById(R.id.call_tv);
				register_tv = (TextView)findViewById(R.id.register_tv);
				//监听
				personal_info_goto.setOnClickListener(this);
				my_consumer_log_goto.setOnClickListener(this);
				my_kuanter_card_goto.setOnClickListener(this);
				my_car_goto.setOnClickListener(this);
				recharge_goto.setOnClickListener(this);
				activate_card_goto.setOnClickListener(this);
				logout_tv.setOnClickListener(this);
		//联网将账户登录信息提交
		if (SharePrefenceUtil.checkLogin(VipCenterActivity.this)) {
			
			if (CheckNetworkState()) {
				List<NameValuePair> params = new ArrayList<NameValuePair>();
				params.add(new BasicNameValuePair("userInfo.mobileNumber",
						getSharedPreferences(SharePrefenceUtil.USERINFO, MODE_PRIVATE).getString("mobileNumber", "-1")));
				params.add(new BasicNameValuePair("userInfo.userPassword",
						getSharedPreferences(SharePrefenceUtil.USERINFO, MODE_PRIVATE).getString("password", "-1")));
				new DataLoader(VipCenterActivity.this).DisplayData(MainConstants.HOST_test+HttpConfigAPI.LOGIN, params , handler_login, "", false);
			}
			
		}
	}

	private void ityoung() {
		
		
		
		//修改信息隐藏与否
		if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
			personal_info_goto.setVisibility(View.VISIBLE);
		}else {
			personal_info_goto.setVisibility(View.GONE);
			
			ServicesActivity.NocticeShow= false; //通知初始化
			lin_cx_ad.setVisibility(View.GONE);
			noticeAll.clear();
			falg = true;
			NocticeShow = false;
		}
		
		/*//改变卡片充值背景圆角与否
		
		if(!SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
			recharge_goto.setBackgroundResource(R.drawable.item_selector);
		}else {
			recharge_goto.setBackgroundResource(R.drawable.item_top_selector);
		}*/
		
		//卡与账户
		
		if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
			my_kuanter_card_goto.setBackgroundResource(R.drawable.item_middle_selector);
		}else {
			my_kuanter_card_goto.setBackgroundResource(R.drawable.item_top_selector);
		}
		
		//退出登录按钮隐身与否
		if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
			logout_tv.setVisibility(View.VISIBLE);
		}else {
			logout_tv.setVisibility(View.GONE);
		}
		//vipcenter left btn
				if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
					call_tv.setVisibility(View.VISIBLE);
					register_tv.setVisibility(View.GONE);
				}else {
					call_tv.setVisibility(View.GONE);
					register_tv.setVisibility(View.VISIBLE);
				}
		
		//登录按钮隐身与否
		if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
			login.setVisibility(View.GONE);
		}else {
			login.setVisibility(View.VISIBLE);
		}
		
		sp = getSharedPreferences(SharePrefenceUtil.USERINFO, MODE_PRIVATE);
		//account  
		if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
			account_include.setVisibility(View.VISIBLE);
		//姓
		
//		personXing.setText(sp.getString("userRealName", "-1").substring(0, 1));
		if("男".equals(sp.getString("sex", "-1"))){
			personXing.setText(sp.getString("userRealName", "-1")+" 先生");
		}else if("女".equals(sp.getString("sex", "-1"))){
			personXing.setText(sp.getString("userRealName", "-1")+" 女士");
		} else {
			personXing.setText(sp.getString("userRealName", "-1"));
		}
		//手机号
		
		personPhone.setText(sp.getString("mobileNumber", "-1").substring(0, 3)+"*****"+sp.getString("mobileNumber", "-1").substring(7));
		//账户金额
		
//		accountTitle.getPaint().setFakeBoldText(true);//加粗
//		accountTitle.setTypeface(Typeface.DEFAULT_BOLD, Typeface.BOLD);
		/*accountJinE = (TextView)this.findViewById(R.id.textView5);
		accountCiShu = (TextView)this.findViewById(R.id.textView11);*/
		//查询卡片
		if(ProApplication.getInstance().getCardInfoList() != null && ProApplication.getInstance().getCardInfoList().size() > 0){
					cardInfos = ProApplication.getInstance().getCardInfoList() ;
					setWelcomeInfo(cardInfos,accountJinE);
		}else {
			dataLoader = new DataLoader(this);
			List<NameValuePair> params = new ArrayList<NameValuePair>();
			//从SharedPreferences本地化数据中区账号信息
			params.add(new BasicNameValuePair("cardInfo.userId",sp.getString("id", "-1")));
			dataLoader.DisplayData(MainConstants.HOST_test
					+ HttpConfigAPI.QUERY_CARD, params, handler_QUERY_CARD, "", false);
			showProgress("正在加载数据...");
		}
		//累计节省
		
		//查询节省
		if(!"".equals(ProApplication.getInstance().getSaveMoney())){
			saveJinE.setText(ProApplication.getInstance().getSaveMoney());
		}else {
			List<NameValuePair> params1 = new ArrayList<NameValuePair>();
			params1.add(new BasicNameValuePair("userId", sp.getString("id", "-1")));
			new DataLoader(this).DisplayData(MainConstants.HOST_test
					+ HttpConfigAPI.SAVE_MONEY, params1, handler, "", false);
			showProgress("正在加载数据...");
		}
		}else {
			account_include.setVisibility(View.GONE);
		}
	}
	//register
	public void register(View v){
		Intent intent = new Intent(this,Register2Activity.class);
		startActivity(intent);
		startActivity_anim(0);
	}
	//call
	public void call(View v){
		/*Intent intentActivite = new Intent(this,ActivateCardActivity.class);
		startActivity(intentActivite);*/
		new AlertDialog.Builder(VipCenterActivity.this).
		setMessage("拨打宽途服务热线: 400-6666-377")
		.setPositiveButton("确认", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				Intent call_intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:4006666377"));
				startActivity(call_intent);
			}
		}).setNegativeButton("取消", null).create().show();
	}
	//登录
	public void login(View v){
		Intent intentLogin = new Intent(this,LoginActivity.class);
		startActivity(intentLogin);
	}
	//无卡支付android:onClick="noCardPay"
	public void noCardPay(View v){
		if(!SharePrefenceUtil.checkLogin(VipCenterActivity.this)) {
			if(HomeActivityGroup.select_id != null) {
				HomeActivityGroup.select_id.add(ProApplication.KUANTER_FW);
			}
			qStartActivity(LoginActivity.class, null, MainConstants.noCardPay_ACTION);
			startActivity_anim(7);
		} else {
			Intent intent = new Intent("com.action.noCardPay");
			startActivity(intent);
		}	
	}
	//车险
	public void insurance(View v){
		if(!SharePrefenceUtil.checkLogin(VipCenterActivity.this)) {
			if(HomeActivityGroup.select_id != null) {
				HomeActivityGroup.select_id.add(ProApplication.KUANTER_FW);
			}
			qStartActivity(LoginActivity.class, null, MainConstants.CX_ACTION);
			startActivity_anim(7);
		} else {
			Intent intent = new Intent("com.action.cx");
			startActivity(intent);
		}	
	}
	//理财android:onClick="financial"
	public void financial(View v){
		if(!SharePrefenceUtil.checkLogin(VipCenterActivity.this)) {
			if(HomeActivityGroup.select_id != null) {
				HomeActivityGroup.select_id.add(ProApplication.KUANTER_FW);
			}
			qStartActivity(LoginActivity.class, null, MainConstants.LC_ACTION);
			startActivity_anim(7);
		} else {
			Intent intent = new Intent("com.action.lc");
			startActivity(intent);
		}
	}
	//关注我们android:onClick="attention_us"
	public void attention_us(View v){
		Intent intentAttention = new Intent(this,AttentionUsActivity.class);
		startActivity(intentAttention);
	}
	//优惠信息android:onClick="preferential"
	public void preferential(View v){
		Intent intentPreferential = new Intent(this,PreferentialActivity.class);
		startActivity(intentPreferential);
	}
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.setting_my_message:
			//我的消息
			//showToast("我的消息");
			intent = new Intent(this,MyMessageActivity.class);
			startActivity(intent);
			break;
		case R.id.personal_info_goto:
			intent.setClass(this, PersonalInfoActivity.class);
			startActivity(intent);
			break;
		case R.id.my_consumer_log_goto:
			/*intent.setClass(this, MyKuanterConsumerActivity.class);
			intent.putExtra("userId", userInfo.getId());
			startActivity(intent);*/
			if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
				Intent in_consumer = new Intent("com.action.consumer");
//				intent.setClass(this, MyKuanterConsumerActivity.class);
				startActivity(in_consumer);
			}else {
				if(HomeActivityGroup.select_id != null) {
					HomeActivityGroup.select_id.add(ProApplication.KUANTER_HY);
				}
				qStartActivity(LoginActivity.class, null,MainConstants.JL_ACTION);
				/*intent.setClass(this, LoginActivity.class);
				startActivity(intent);*/
			}
			
			break;
		case R.id.my_kuanter_card_goto:
			if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
				intent.setClass(this, CardAndAccountActivity.class);
				startActivity(intent);
			}else {
				if(HomeActivityGroup.select_id != null) {
					HomeActivityGroup.select_id.add(ProApplication.KUANTER_HY);
				}
				qStartActivity(LoginActivity.class, null,MainConstants.KZ_ACTION);
				/*intent.setClass(this, LoginActivity.class);
				startActivity(intent);*/
			}
			break;
		case R.id.my_car_goto:
			/*intent.setClass(this, MyCarActivity.class);
			startActivity(intent);*/
			if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
				intent.setClass(this, MyCarActivity.class);
				startActivity(intent);
			}else {
				if(HomeActivityGroup.select_id != null) {
					HomeActivityGroup.select_id.add(ProApplication.KUANTER_HY);
				}
				qStartActivity(LoginActivity.class, null,MainConstants.CL_ACTION);
				/*intent.setClass(this, LoginActivity.class);
				startActivity(intent);*/
			}
			break;
		case R.id.logout_tv:
			ServicesActivity.NocticeShow= false; //通知初始化
			
			application.setSaveMoney("");
			ObjectCache.clear();
			application.clearCache();
			ProApplication.getInstance().setUserInfo(null);
			List<VehicleInfo> list = ProApplication.getInstance().getList_vehicleInfo();
			if(list != null) {
				list.clear();
				list = null;
			}
			if(null != CarListAdapter.vehicleInfos){
				CarListAdapter.vehicleInfos.clear();
			}
			if(ProApplication.getInstance().getCardInfoList() != null){
				ProApplication.getInstance().setCardInfoList(null);
			}
			SharePrefenceUtil.clear(this);
			HomeActivityGroup.backAction = "";
			intent = new Intent(MainConstants.Data_ACTION);
			sendBroadcast(intent);
			
			lin_cx_ad.setVisibility(View.GONE);
			noticeAll.clear();
			falg = false;
			NocticeShow = false;
			
			break;
		case R.id.recharge_goto:
			if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
				intent.setClass(this, Recharge3Activity.class); 
				startActivity(intent);
			}else {
				if(HomeActivityGroup.select_id != null) {
					HomeActivityGroup.select_id.add(ProApplication.KUANTER_HY);
				}
				qStartActivity(LoginActivity.class, null,MainConstants.CZ_ACTION);
			}
			break;
		}
	}
	
	public void activateCard(View v){
//		intent.setClass(this, ActivateCardActivity.class);
//		startActivity(intent);
		Intent active_card = new Intent(VipCenterActivity.this, NewActivation.class);
		startActivity(active_card);
	}
	/*public void recharge(View v){
		if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
			intent.setClass(this, RechargeActivity.class); 
			startActivity(intent);
		}else {
			if(HomeActivityGroup.select_id != null) {
				HomeActivityGroup.select_id.add(ProApplication.KUANTER_HY);
			}
			qStartActivity(LoginActivity.class, null,MainConstants.CZ_ACTION);
		}
		
	}*/

	@Override
	protected void onResume() {
		noticeAll.clear();
		
		MerchantTurnActivity2.sh = false;
		/*//改变卡片充值背景圆角与否
				if(!SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
					recharge_goto.setBackgroundResource(R.drawable.item_selector);
				}else {
					recharge_goto.setBackgroundResource(R.drawable.item_top_selector);
				}*/
		//vipcenter left btn
		if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
			call_tv.setVisibility(View.VISIBLE);
			register_tv.setVisibility(View.GONE);
		}else {
			call_tv.setVisibility(View.GONE);
			register_tv.setVisibility(View.VISIBLE);
		}
		//修改信息隐藏与否
		if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
			personal_info_goto.setVisibility(View.VISIBLE);
		}else {
			personal_info_goto.setVisibility(View.GONE);
		}
		//卡与账户
				if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
					my_kuanter_card_goto.setBackgroundResource(R.drawable.item_middle_selector);
				}else {
					my_kuanter_card_goto.setBackgroundResource(R.drawable.item_top_selector);
				}
		//退出登录按钮隐身与否
				if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
					logout_tv.setVisibility(View.VISIBLE);
				}else {
					logout_tv.setVisibility(View.GONE);
				}
				//登录按钮隐身与否
				if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
					login.setVisibility(View.GONE);
				}else {
					login.setVisibility(View.VISIBLE);
				}
				//account  
				if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)){
					account_include = this.findViewById(R.id.account_include);
					account_include.setVisibility(View.VISIBLE);
				//姓
				personXing = (TextView)this.findViewById(R.id.textView2);
//				personXing.setText(sp.getString("userRealName", "-1").substring(0, 1));
				if("男".equals(sp.getString("sex", "-1"))){
					personXing.setText(sp.getString("userRealName", "-1")+" 先生");
				}else if("女".equals(sp.getString("sex", "-1"))){
					personXing.setText(sp.getString("userRealName", "-1")+" 女士");
				} else {
					personXing.setText(sp.getString("userRealName", "-1"));
				}
				//手机号
				personPhone = (TextView)this.findViewById(R.id.textView3);
				personPhone.setText(sp.getString("mobileNumber", "-1").substring(0, 3)+"*****"+sp.getString("mobileNumber", "-1").substring(7));
				//账户金额
				accountTitle = (TextView)this.findViewById(R.id.textView4);
//				accountTitle.getPaint().setFakeBoldText(true);//加粗
//				accountTitle.setTypeface(Typeface.DEFAULT_BOLD, Typeface.BOLD);
				/*accountJinE = (TextView)this.findViewById(R.id.textView5);
				accountCiShu = (TextView)this.findViewById(R.id.textView11);*/
				//查询卡片
				if(ProApplication.getInstance().getCardInfoList() != null && ProApplication.getInstance().getCardInfoList().size() > 0){
					cardInfos = ProApplication.getInstance().getCardInfoList() ;
					setWelcomeInfo(cardInfos,accountJinE);
				}else {
					dataLoader = new DataLoader(this);
					List<NameValuePair> params = new ArrayList<NameValuePair>();
					//从SharedPreferences本地化数据中区账号信息
					params.add(new BasicNameValuePair("cardInfo.userId",sp.getString("id", "-1")));
					dataLoader.DisplayData(MainConstants.HOST_test
							+ HttpConfigAPI.QUERY_CARD, params, handler_QUERY_CARD, "", false);
					showProgress("正在加载数据...");
				}
				//累计节省
				saveTitle = (TextView)this.findViewById(R.id.textView9);
//				saveTitle.getPaint().setFakeBoldText(true);//加粗  
				saveJinE = (TextView)this.findViewById(R.id.textView6);
				//查询节省
				if(!"".equals(ProApplication.getInstance().getSaveMoney())){
					saveJinE.setText(ProApplication.getInstance().getSaveMoney());
				}else {
					List<NameValuePair> params1 = new ArrayList<NameValuePair>();
					params1.add(new BasicNameValuePair("userId", sp.getString("id", "-1")));
					new DataLoader(this).DisplayData(MainConstants.HOST_test
							+ HttpConfigAPI.SAVE_MONEY, params1, handler, "", false);
					showProgress("正在加载数据...");
				}
				}else {
					account_include = this.findViewById(R.id.account_include);
					account_include.setVisibility(View.GONE);
				}
				
				//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
				lin_cx_ad = (LinearLayout) findViewById(R.id.lin_cx_ad);   
				deleteit = (ImageView) findViewById(R.id.deleteit);
				deleteit.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View arg0) {
						lin_cx_ad.setVisibility(View.GONE);
						falg = false;
						NocticeShow = true;
					}
				});
				
				first_ad = (TextView) findViewById(R.id.first_ad);
				next_ad = (TextView) findViewById(R.id.next_ad);
//				new Thread(run_ad).start();  TODO
				
				if(SharePrefenceUtil.checkLogin(VipCenterActivity.this)) {
					if(application.getList_vehicleInfo() == null || application.getList_vehicleInfo().size() == 0) {
						DataLoader loader_car = new DataLoader(VipCenterActivity.this);
						String url_car = MainConstants.HOST_test + HttpConfigAPI.FINDVEHICLE;
						List<NameValuePair> list_car = new ArrayList<NameValuePair>();
						NameValuePair params_car = new BasicNameValuePair("vehicleInfo.userId", SharePrefenceUtil.getUserID(VipCenterActivity.this) + "");
						list_car.add(params_car);
						loader_car.DisplayData(url_car, list_car, mHandlerVie, "", false);
					} else {
						for(int i = 0; i < application.getList_vehicleInfo().size(); i++) {
							VehicleInfo vi = application.getList_vehicleInfo().get(i);
							String endTime_insurance = vi.getInsuranceEndTime();
							if(checkWetherExpire(endTime_insurance,noticeday)) {
								noticeAll.add("车" + vi.getLicensePlateNumber());
							}
							
							String endTime_yearChager = vi.getInspectionExpireTime();
							if(checkWetherExpire(endTime_yearChager, noticeday)) {
								noticeAll.add("年" + vi.getLicensePlateNumber());
							}
						}
						if(thread != null && thread.isAlive()) {
							
						} else {
							thread = new Thread(run_ad);
							thread.start();
						}
					}
				}
				
				//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
		super.onResume();
	}
	
	@Override
	public void onWindowFocusChanged(boolean hasFocus) {
		handler.postDelayed(new Runnable() {
			@Override
			public void run() {
				vip_scroll.scrollTo(0, 0);
				if(toastJH) {
					vip_toast.setVisibility(View.VISIBLE);
					myMearse();
					iv_jh_ok.setImageResource(R.drawable.jh_ok);
					android.widget.RelativeLayout.LayoutParams iv_top_rp = (android.widget.RelativeLayout.LayoutParams) iv_jh_ok.getLayoutParams();
					iv_top_rp.topMargin = DimensUtil.dipTopx(VipCenterActivity.this, 30);
					re_zh.setVisibility(View.VISIBLE);
					toastJH = false;
				} else if(toastZC) {
					vip_toast.setVisibility(View.VISIBLE);
					myMearse();
					iv_jh_ok.setImageResource(R.drawable.toast_zc);
					android.widget.RelativeLayout.LayoutParams iv_top_rp = (android.widget.RelativeLayout.LayoutParams) iv_jh_ok.getLayoutParams();
					iv_top_rp.topMargin = DimensUtil.dipTopx(VipCenterActivity.this, 90);
					re_zh.setVisibility(View.GONE);
					toastZC = false;
				} else {
					vip_toast.setVisibility(View.GONE);
				}
			}
		}, 100);
		
		super.onWindowFocusChanged(hasFocus);
	}

	@Override
	protected void onDestroy() {
		MerchantTurnActivity2.sh = false;
		super.onDestroy();
	}
	
	//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
///////////////////////////////////////////////////////////////////////////////////
	public static int noticeDayInsurance = 5;
	public static int noticeDayYearCharge = 90;
	
	int[] noticeday = new int[]{2,5,30}; 
	
	List<String> noticeAll = new ArrayList<String>();
	LinearLayout lin_cx_ad;
	ImageView deleteit;
	TextView first_ad;
	TextView next_ad;
	public static boolean NocticeShow = false;
	
	Thread thread;
	
/*
* 得到车险
*/
	Handler mHandlerVie = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			if (msg.what == HttpTask.RESULT_OK) {
				String json = (String) msg.obj;
				VehicleInfoList vif = new VehicleInfoList(json);
				List<VehicleInfo> listVi = vif.getVehicleInfoList();
				if (application != null) {
					application.setList_vehicleInfo(listVi);

				}
				if (listVi != null) {
					for (int i = 0; i < listVi.size(); i++) {
						VehicleInfo vi = listVi.get(i);
						String endTime_insurance = vi.getInsuranceEndTime();
						if (checkWetherExpire(endTime_insurance, noticeday)) {
							noticeAll.add("车" + vi.getLicensePlateNumber());
						}

						String endTime_yearChager = vi
								.getInspectionExpireTime();
						if (checkWetherExpire(endTime_yearChager, noticeday)) {
							noticeAll.add("年" + vi.getLicensePlateNumber());
						}

					}
				}

//				new Thread(run_ad).start();
				if(thread != null && thread.isAlive()) {
//					thread.start();
				} else {
					thread = new Thread(run_ad);
					thread.start();
				}
			}
			super.handleMessage(msg);
		}

	};

	public boolean checkWetherExpire(String endTime, int[] expireTime) {
		boolean flag = false;
		if (endTime != null && !endTime.equals("") && !endTime.equals("null")) {

			DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			try {
				Date endDate = df.parse(endTime);
				Date now = new Date();
				long diff = endDate.getTime() - now.getTime();
				long day = diff / (1000 * 60 * 60 * 24);
				/*
				 * if(day < expireTime && day >= 0) { flag = true; }
				 */
				for (int i = 0; i < expireTime.length; i++) {
					if (day == expireTime[i]) {
						flag = true;
					}
				}
			} catch (ParseException e) {
				e.printStackTrace();
			}

		}
		return flag;
	}

	// --------------------------
	int i = 0; // notice标记

	int nums = 0;

	boolean falg = true;
	Runnable run_ad = new Runnable() {
		@Override
		public void run() {
			
			while (falg) {
				if (!NocticeShow) {
					for (int i = 0; i < noticeAll.size(); i++) {
						if (falg) {
							ad_handler_1.sendEmptyMessage(nums);
							try {
								Thread.sleep(5000);
							} catch (InterruptedException e) {
								e.printStackTrace();
							}
						}
						nums++;
					}
					if (falg) {
//						if (noticeAll.size() > 0) {
							/*
							 * ad_handler_1.sendEmptyMessage(noticeAll.size());
							 * 
							 * try { Thread.sleep(5000); } catch
							 * (InterruptedException e) { e.printStackTrace(); }
							 */
//						}
					}
					// NocticeShow = true;
				} else {
					falg = false;
				}

			}
		}
	};

	/**
	 * 车险通知1
	 */
	Handler ad_handler_1 = new Handler() {

		@Override
		public void handleMessage(Message msg) {
			AnimationController ac = new AnimationController();

			int loc = msg.what % (noticeAll.size());
			String notice = "";
			if (noticeAll.get(loc).substring(0, 1).equals("年")) {
				notice = " 的年审时间即将到期";
			} else {
				notice = " 的车险时间即将到期";
			}

			if (msg.what % 2 != 0) {
				lin_cx_ad.setVisibility(View.VISIBLE);
				next_ad.setText(noticeAll.get(loc).substring(1,
						noticeAll.get(loc).length())
						+ notice);
				ac.slideInY(next_ad, 800, 0);
				ac.slideOutY(first_ad, 800, 0);
			} else {
				lin_cx_ad.setVisibility(View.VISIBLE);
				first_ad.setText(noticeAll.get(loc).substring(1,
						noticeAll.get(loc).length())
						+ notice);
				ac.slideInY(first_ad, 800, 0);
				ac.slideOutY(next_ad, 800, 0);
			}

			super.handleMessage(msg);
		}

	};

	/*
	 * 车险通知
	 */
	Handler ad_handler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			AnimationController ac = new AnimationController();
			if (msg.what != noticeAll.size() && msg.what == 0) {
				String notice = "";
				if (noticeAll.get(0).substring(0, 1).equals("年")) {
					notice = " 的年审时间即将到期";
				} else {
					notice = " 的车险时间即将到期";
				}
				first_ad.setText(noticeAll.get(0).subSequence(1,
						noticeAll.get(0).length())
						+ notice);
				// lin_cx_ad.setVisibility(View.VISIBLE);
				// first_ad.setVisibility(View.VISIBLE);
				// next_ad.setVisibility(View.GONE);

				lin_cx_ad.setVisibility(View.VISIBLE);
				first_ad.setText(noticeAll.get(0).substring(1,
						noticeAll.get(0).length())
						+ notice);
				ac.slideInY(first_ad, 800, 0);
				ac.slideOutY(next_ad, 800, 0);

			} else if (msg.what != noticeAll.size() && msg.what >= 1) {
				String notice = "";
				if (noticeAll.get(msg.what).substring(0, 1).equals("年")) {
					notice = " 的年审时间即将到期";
				} else {
					notice = " 的车险时间即将到期";
				}
				if (msg.what % 2 != 0) {
					lin_cx_ad.setVisibility(View.VISIBLE);
					next_ad.setText(noticeAll.get(msg.what).substring(1,
							noticeAll.get(msg.what).length())
							+ notice);
					ac.slideInY(next_ad, 800, 0);
					ac.slideOutY(first_ad, 800, 0);
				} else {
					lin_cx_ad.setVisibility(View.VISIBLE);
					first_ad.setText(noticeAll.get(msg.what).substring(1,
							noticeAll.get(msg.what).length())
							+ notice);
					ac.slideInY(first_ad, 800, 0);
					ac.slideOutY(next_ad, 800, 0);
				}
			} else if (msg.what == noticeAll.size()) { // 结束
				if (noticeAll.size() > 0) {

					String notice = "";
					if (noticeAll.get(0).substring(0, 1).equals("年")) {
						notice = " 的年审时间即将到期";
					} else {
						notice = " 的车险时间即将到期";
					}
					if ((msg.what - 1) % 2 != 0) {
						lin_cx_ad.setVisibility(View.VISIBLE);
						next_ad.setText(noticeAll.get(0).substring(1,
								noticeAll.get(0).length())
								+ notice);
						ac.slideInY(next_ad, 800, 0);
						ac.slideOutY(first_ad, 800, 0);
					} else {
						lin_cx_ad.setVisibility(View.VISIBLE);
						first_ad.setText(noticeAll.get(0).substring(1,
								noticeAll.get(0).length())
								+ notice);
						ac.slideInY(first_ad, 800, 0);
						ac.slideOutY(next_ad, 800, 0);
					}
				}
			}
			super.handleMessage(msg);
		}

	};
	
	public void myMearse() {
		int ad_height = 0;
		if(lin_cx_ad.isShown()) {
			ad_height = lin_cx_ad.getHeight();
		}
		
		int noCardPayPositionHeight = noCardPayPosition.getMeasuredHeight();
		int top = noCardPayPosition.getTop();
		int noCardPayPositionLeft = noCardPayPosition.getLeft() + DimensUtil.dipTopx(VipCenterActivity.this, 10);// + DimensUtil.dipTopx(VipCenterActivity.this, 20); //TODO
		int noCardPayPositionRight = tmp123.getRight() + noCardPayPosition.getLeft();
		int noCardPayPositionWith = noCardPayPositionRight - noCardPayPositionLeft;
//		RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(noCardPayPositionWith, noCardPayPositionHeight);
		LinearLayout.LayoutParams rlp = new LinearLayout.LayoutParams(noCardPayPositionWith + DimensUtil.dipTopx(VipCenterActivity.this, 10), noCardPayPositionHeight);
		int top_top = lin_top.getMeasuredHeight();
//		rlp.topMargin = top + top_top + DimensUtil.dipTopx(VipCenterActivity.this, 3) + ad_height;  //它的位置+顶部+阴影+车险提醒
//		rlp.leftMargin = noCardPayPositionLeft;  //自己位置
		location2noCardPay.setLayoutParams(rlp);
		
//		RelativeLayout.LayoutParams lp = (android.widget.RelativeLayout.LayoutParams) iv_toast_cz.getLayoutParams();
//		lp.topMargin = noCardPayPositionHeight;  //相对上一个无卡支付距离为一个 圆角的高度
//		lp.height = noCardPayPositionHeight;
		LinearLayout.LayoutParams lp_cz = new LinearLayout.LayoutParams(noCardPayPositionWith + DimensUtil.dipTopx(VipCenterActivity.this, 10), noCardPayPositionHeight);
		lp_cz.height = noCardPayPositionHeight;
		iv_toast_cz.setLayoutParams(lp_cz);
		
		int left = rl_account_3_lines.getLeft();
		int height_3 = rl_account_3_lines.getMeasuredHeight();
		int height_2 = rl_account_2_lines.getMeasuredHeight();
		
		int top_jf = layout_re_top.getTop();
		
		int width = 0;
		
		int height = 0;
		int top_zi = 0;
		if(rl_account_3_lines.isShown()) {
			height = height_3 + 20;  //TODO  (20表示高度多加10，内边距都为10)
			top_zi = rl_account_3_lines.getTop();
			
			width = rl_account_3_lines.getWidth();
		} else if(rl_account_2_lines.isShown()) {
			height = height_2 + 20;  //TODO
			top_zi = rl_account_2_lines.getTop();
			
			width = rl_account_2_lines.getWidth();
		}
		int marginleft = noCardPayPosition.getLeft() + left - 15;  //TODO
		LinearLayout.LayoutParams lp_p = new LinearLayout.LayoutParams(width + 30, height);
//		lp_p.leftMargin = marginleft;
//		lp_p.topMargin = top_jf + top_top + DimensUtil.dipTopx(VipCenterActivity.this, 3) + top_zi - 10 + ad_height;  //TODO  黄色距最顶部的距离+顶部+阴影+充值字距上黄色的高度 + 车险窗口(10表示框框内边距)
		iv_jf.setLayoutParams(lp_p);
		
		RelativeLayout.LayoutParams lllp = new RelativeLayout.LayoutParams(android.widget.RelativeLayout.LayoutParams.FILL_PARENT, height);
		lllp.leftMargin = marginleft;
		lllp.topMargin = top_jf + top_top + DimensUtil.dipTopx(VipCenterActivity.this, 3) + top_zi - 10 + ad_height;  //TODO  黄色距最顶部的距离+顶部+阴影+充值字距上黄色的高度 + 车险窗口(10表示框框内边距)
		re_zh.setLayoutParams(lllp);
		
		RelativeLayout.LayoutParams rl_wk = new RelativeLayout.LayoutParams(android.widget.RelativeLayout.LayoutParams.FILL_PARENT, noCardPayPositionHeight);
		rl_wk.topMargin = top + top_top + DimensUtil.dipTopx(VipCenterActivity.this, 3) + ad_height;  //它的位置+顶部+阴影+车险提醒
		rl_wk.leftMargin = noCardPayPositionLeft;  //自己位置
		re_wk.setLayoutParams(rl_wk);
		
		RelativeLayout.LayoutParams rl_cz =(android.widget.RelativeLayout.LayoutParams) re_cz.getLayoutParams();
		rl_cz.topMargin = noCardPayPositionHeight;  //相对上一个无卡支付距离为一个 圆角的高度
		rl_cz.height = noCardPayPositionHeight;
		re_cz.setLayoutParams(rl_cz);
	}
	
	public void myMearse1() {
		int ad_height = 0;
		if(lin_cx_ad.isShown()) {
			ad_height = lin_cx_ad.getHeight();
		}
		
		int noCardPayPositionHeight = noCardPayPosition.getMeasuredHeight();
		int top = noCardPayPosition.getTop();
		int noCardPayPositionLeft = noCardPayPosition.getLeft() + 5;// + DimensUtil.dipTopx(VipCenterActivity.this, 20); //TODO
		int noCardPayPositionRight = tmp123.getRight() + noCardPayPosition.getLeft();
		int noCardPayPositionWith = noCardPayPositionRight - noCardPayPositionLeft;
//		RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(noCardPayPositionWith, noCardPayPositionHeight);
		RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT, noCardPayPositionHeight);
		int top_top = lin_top.getMeasuredHeight();
		rlp.topMargin = top + top_top + DimensUtil.dipTopx(VipCenterActivity.this, 3) + ad_height;  //它的位置+顶部+阴影+车险提醒
		rlp.leftMargin = noCardPayPositionLeft;  //自己位置
		location2noCardPay.setLayoutParams(rlp);
		location2noCardPay.setImageResource(R.drawable.toast_wk);
		
		RelativeLayout.LayoutParams lp = (android.widget.RelativeLayout.LayoutParams) iv_toast_cz.getLayoutParams();
		lp.topMargin = noCardPayPositionHeight;  //相对上一个无卡支付距离为一个 圆角的高度
		lp.height = noCardPayPositionHeight;
		iv_toast_cz.setLayoutParams(lp);
		iv_toast_cz.setImageResource(R.drawable.toast_cz);
		
		int left = rl_account_3_lines.getLeft();
		int height_3 = rl_account_3_lines.getMeasuredHeight();
		int height_2 = rl_account_2_lines.getMeasuredHeight();
		
		int top_jf = layout_re_top.getTop();
		
		int width = 0;
		
		int height = 0;
		int top_zi = 0;
		height = layout_re_top.getHeight();
		if(rl_account_3_lines.isShown()) {
//			height = height_3 + 20;  //TODO  (20表示高度多加10，内边距都为10)
			top_zi = rl_account_3_lines.getTop();
			
			width = rl_account_3_lines.getWidth();
		} else if(rl_account_2_lines.isShown()) {
//			height = height_2 + 20;  //TODO
			top_zi = rl_account_2_lines.getTop();
			
			width = rl_account_2_lines.getWidth();
		}
		int marginleft = noCardPayPosition.getLeft() + left - 10;  //TODO
		RelativeLayout.LayoutParams lp_p = new RelativeLayout.LayoutParams(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT, height);
		lp_p.leftMargin = marginleft;
//		lp_p.topMargin = top_jf + top_top + DimensUtil.dipTopx(VipCenterActivity.this, 3) + top_zi - 10 + ad_height;  //TODO  黄色距最顶部的距离+顶部+阴影+充值字距上黄色的高度 + 车险窗口(10表示框框内边距)
		lp_p.topMargin = top_jf + top_top + DimensUtil.dipTopx(VipCenterActivity.this, 3) + ad_height;  //TODO  黄色距最顶部的距离+顶部+阴影 + 车险窗口
		iv_jf.setLayoutParams(lp_p);
		
	}

	// --------------------------------
	class GetMessage extends BroadcastReceiver {
		@Override
		public void onReceive(Context context, Intent intent) {
			//获取新消息数
			int messageNumber = PushServices.unReadMessage;
			DrawNumber drawNumber = new DrawNumber(VipCenterActivity.this);
			
			View v = factory.inflate(R.layout.draw_number, null);
//			if(null != PushServices.getmessageInfos()){
//				messageNumber = PushServices.getmessageInfos().size();
				if(messageNumber > 0){
					bubble.setVisibility(View.VISIBLE);
					Bitmap bitmap = drawNumber.generatorContactCountIcon(drawNumber.convertViewToBitmap(v),messageNumber);
					bubble.setImageBitmap(bitmap);
				}else{
					bubble.setVisibility(View.GONE);
				}
//			}
			/*else{
				bubble.setVisibility(View.GONE);*/
//			}
		}
		
	}
}
